package cn.csq.rpc.server;

import cn.csq.rpc.Request;
import com.csq.rpc.common.utils.ReflectionUtils;
import lombok.extern.slf4j.Slf4j;

/**
 * invoke 调用具体服务
 * @author chengshanqing
 * @date Created in 2021/12/20 13:27
 */
@Slf4j
public class ServiceInvoker {

    public Object invoke(ServiceInstance service, Request request) {
        try {
            return ReflectionUtils.invoke(service.getTarget(), service.getMethod(), request.getParameters());
        } catch (IllegalAccessException e) {
            log.error("serviceInvoker invoke error", e);
            return null;
        }
    }
}
